package edu.nf.project.mappers.storeOperation.convention;

import edu.nf.project.entitys.enums.storeOperation.InventoryLock;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * @Author gjh
 * @Date 2025/6/20
 * @Description:
 */
public interface InventoryLockMapper {
    @Insert("INSERT INTO inventory_lock(order_id, cargo_id, quantity, status) VALUES(#{orderId}, #{cargoId}, #{quantity}, #{status})")
    void insert(InventoryLock lock);

    @Select("SELECT * FROM inventory_lock WHERE order_id = #{orderId} AND status = 'LOCKED'")
    List<InventoryLock> findLockedByOrderId(@Param("orderId") Long orderId);

    @Update("UPDATE inventory_lock SET status = #{status} WHERE id = #{id}")
    void updateStatus(@Param("id") Integer id, @Param("status") String status);

}
